package com.example.supermarket_back.config.filter;


import com.example.supermarket_back.config.cache.CacheConfig;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

//拦截器
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Resource
    private CacheConfig cacheConfig;

    @Override//拦截器
    public void addInterceptors(InterceptorRegistry registry) {
        //指定拦截的请求uri地址
        String[] path={"/**"};
        String[] excludePath={"/login/**","/register/**"};
        //指定不拦截的地址
        registry.addInterceptor(new RequestInterceptor(cacheConfig))
                .addPathPatterns(path)
                .excludePathPatterns(excludePath);
    }
}
